package eerbaar.client.internal.exp;

import java.util.List;

import eerbaar.client.exp.ICmdFactory;
import eerbaar.client.exp.IEvaluator;
import eerbaar.client.exp.IExpService;
import eerbaar.client.exp.INounFactory;
import eerbaar.client.exp.IOperatorFactory;
import eerbaar.client.exp.Token;
import eerbaar.client.exp.TokenIterator;
import eerbaar.shared.tree.INode;

public class ExpService implements IExpService {

    @Override
    public IEvaluator evaluator(INode root, ICmdFactory factory,
            IOperatorFactory operatorFactory, INounFactory nounFactory) {

        return new Evaluator(root, factory, operatorFactory, nounFactory);
    }

    @Override
    public IEvaluator evaluator(IOperatorFactory operatorFactory,
            INounFactory nounFactory) {

        return new Evaluator(operatorFactory, nounFactory);
    }

    @Override
    public TokenIterator scan(String expression) {

        Scanner scanner = new Scanner();
        List<Token> tokens = scanner.scan(expression);
        return new TokenIterator(tokens);
    }

}
